<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>公共嵌套模板</title>
</head>
<body>

<th:block th:fragment="baseJsCss">
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">

    <link rel="shortcut icon" href="/static/logo.svg"/>
    <link rel="stylesheet" href="/static/plugins/pace/themes/custom/green/pace-theme-center-atom.css">
    <link rel="stylesheet" href="/static/lay/layui/css/layui.css?v=1.1" media="all">
    <link rel="stylesheet" href="/static/lay/style/zmn.lay.extend.css?v=1.1" media="all">
    <link rel="stylesheet" href="/static/lay/style/admin.css?v=1.2" media="all">
    <link rel="stylesheet" href="//img1.xiujiadian.com/static/common/styles/common.min.css">
    <link rel="stylesheet" href="/static/lay/style/formSelects-v4.css?v=1.2" media="all">
    <!--自定义图标-->
    <script src="/static/lay/layui/extend-icon/iconfont.js"></script>

    <script src="/static/lay/layui/layui.js?v=1.1"></script>
    <script src="/static/js/zmn.lay.js?v=0402"></script>
    <script src="/static/js/zmn.lay.util.js?v=1.1"></script>
    <script src="/static/lay/layui/formSelects-v4.js?v=1.1"></script>
    <script src="/static/js/numberPrecision.js?v=1.1"></script>
    <script src="/static/lay/layui/xm-select.js?v=1.1"></script>
    <!--<script src="/js/zmn.echarts.js"></script>-->

    <!--<script th:src="|${session.RES.value}/static/js/common/zmn.lay.config.min.js|"></script>-->
    <script src="//img1.xiujiadian.com/static/common/layui/zmn.layui.config.js"></script>
    <script>
        document.domain = "xiujiadian.com";
    </script>

    <style type="text/css">

        .layui-form-required:after {
            content: none;
        }

        .icon {
            width: 1.1em;
            height: 1.1em;
            vertical-align: -0.23em;
            fill: currentColor;
            overflow: hidden;
        }

    </style>

    <script type="text/javascript">
        /**
         * 通过window.addEventListener来监听amis发送过来的信息,进行相关的layui操作
         */
        window.addEventListener("message", (event) => {

            //打开一个tab
            if (event.data.type === "OPEN_TAB") {
                layui.index.openTabsPage(event.data.url, event.data.title);
            }

            //关闭当前tab
            if (event.data.type === "CLOSE_TAB") {
                layui.admin.events.closeThisTabs();
            }
        }, false);
    </script>

</th:block>

<th:block th:fragment="baseJsCss2">
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">

    <script>document.domain = 'xiujiadian.com'</script>
    <link rel="shortcut icon" th:href="${ZMN_URL_ENV}+'res.xiujiadian.com/static/favicon.ico'"/>


    <link rel="stylesheet" th:href="${ZMN_URL_ENV}+'res.xiujiadian.com/static/lay/layui/css/layui.min.css'">
    <link rel="stylesheet" th:href="${ZMN_URL_ENV}+'res.xiujiadian.com/static/lay/style/admin.min.css?v=1.0'">
    <link rel="stylesheet" th:href="${ZMN_URL_ENV}+'res.xiujiadian.com/static/js/extends/treeTable/treeTable.css'">
    <script th:src="${ZMN_URL_ENV}+'res.xiujiadian.com/static/lay/layui/layui.min.js?v=1.2'"></script>
    <script th:src="${ZMN_URL_ENV}+'res.xiujiadian.com/static/js/common/zmn.lay.min.js?v=1.2'"></script>
    <script th:src="${ZMN_URL_ENV}+'res.xiujiadian.com/static/js/common/zmn.lay.config.min.js?v=1.2'"></script>
    <script th:src="${ZMN_URL_ENV}+'res.xiujiadian.com/static/js/common/zmn.lay.util.min.js?v=1.2'"></script>

    <link rel="stylesheet" href="/static/plugins/pace/themes/custom/green/pace-theme-center-atom.css">

    <link rel="stylesheet" href="/static/lay/style/zmn.lay.extend.css?v=1.1" media="all">

    <link rel="stylesheet" href="//img1.xiujiadian.com/static/common/styles/common.min.css">
    <link rel="stylesheet" href="/static/lay/style/formSelects-v4.css?v=1.2" media="all">
    <link rel="stylesheet" href="/static/style/style.css?v=1.3">
    <!--自定义图标-->
    <script src="/static/lay/layui/extend-icon/iconfont.js"></script>

    <script src="/static/js/numberPrecision.js?v=1.1"></script>

    <style type="text/css">
        .layui-form-required:after {
            content: none;
        }
    </style>
    <script>
        document.domain = "xiujiadian.com";
    </script>
</th:block>

<th:block th:fragment="jscss2">
    <script th:inline="javascript">
        window.paceOptions = {
            restartOnRequestAfter: false
        };

        var SYS_BASE_URL_ENUM = {
            oms: [[${session.OMS.value}]]
        };
    </script>
    <script src="/static/plugins/pace/pace.js"></script>
    <th:block th:replace=":: baseJsCss2"/>
</th:block>

<!-- jscss -->
<th:block th:fragment="jscss">
    <script th:inline="javascript">
        window.paceOptions = {
            restartOnRequestAfter: false
        };
        var SYS_BASE_URL_ENUM = {
            oms: [[${session.OMS.value}]]
        };
    </script>
    <script src="/static/plugins/pace/pace.js"></script>
    <th:block th:replace=":: baseJsCss"/>
</th:block>

<!-- menucss -->
<th:block th:fragment="menucss">
    <!--菜单配置-->
    <script type="text/javascript" th:inline="javascript">
        layui.config({
            base: "/static/lay/"
        }).extend({
            index: "lib/index"
        }).use(['index', 'element'], function () {
            let $ = layui.$;
            let element = layui.element;
            let layer = layui.layer;
            let HTML = '';
            window._clickHandler = function (menuInfo) {
                let requestBody = {
                    menuName: menuInfo.split(',')[0],
                    menuUrl: menuInfo.split(',')[1]
                }
                console.log(JSON.stringify(requestBody));
                $.ajax({
                    type: "POST", dataType: "json", data: JSON.stringify(requestBody),
                    url: "/base/homePage/recentlyUsedMenu/add",
                    contentType: "application/json",
                    success: function (result) {
                        if (result.status == 200) {
                            console.log("add menu success");
                        } else {
                            console.log("add menu error" + result.message);
                            return false;
                        }
                    }
                });
            }
            $.ajax({
                type: "POST", dataType: "json", data: null,
                url: "/menu/loadMenu.action",
                contentType: "application/json",
                success: function (result) {
                    if (result.status == 200) {
                        let data = result.data;
                        // 拼接HTML
                        for (var i = 0; i < data.length; i++) {
                            HTML += loadMenu(data[i])
                        }
                        $("#menu").html(HTML);
                        element.init();

                    } else {
                        layer.msg("菜单获取失败", {"icon": 2});
                        return false;
                    }
                }
            });
        });

        // 拼接HTML
        function loadMenu(data) {

            var html = "";
            // 类型为目录
            if (data.menuType == 1) {
                html += '<block>\n';
                if (data.menuLevel == 1) {
                    html += '<a href="javascript:void(0);" style="margin-top: 9px"><svg class="icon"><use xlink:href="#' + data.menuIcon + '"></use></svg>' + data.menuName + '</a>\n';
                } else {
                    html += '<a href="javascript:void(0);"><svg class="icon"><use xlink:href="#' + data.menuIcon + '"></use></svg>' + data.menuName + '</a>\n';
                }
                html += '<dl class="layui-nav-child">\n';
                // 有子集
                if (data.subMenuList !== undefined && data.subMenuList !== null && data.subMenuList.length > 0) {
                    for (var i = 0; i < data.subMenuList.length; i++) {
                        html += loadMenu(data.subMenuList[i]);
                    }
                }
                html += '</dl>\n';
                html += '</block>\n';
            } else {
                let url = location.href.indexOf('local-plat.xiujiadian.com') >= 0 ? data.menuUrl.replace("dev-plat.xiujiadian.com", "local-plat.xiujiadian.com:10113") : data.menuUrl;
                html += '<dd>\n';
                html += '<a class="menu" onclick="_clickHandler(\'' + data.menuName + ',' + data.menuUrl + '\')"   lay-href="' + url + '"><svg class="icon"><use xlink:href="#' + data.menuIcon + '"></use></svg>' + data.menuName + '</a>\n';
                html += '</dd>\n';

            }
            return html;
        };
    </script>
</th:block>

<!-- nav-menu -->
<div th:fragment="nav-menu">
    <li class="selected"><a href="http://plat.zmn.cn/" target="_blank">平台管理</a></li>
    <li><a href="http://oms.zmn.cn/" target="_blank">OMS</a></li>
    <li><a href="http://crm.zmn.cn/" target="_blank">CC/CRM</a></li>
    <li><a href="http://scm.zmn.cn/" target="_blank">SCM</a></li>
</div>

<!-- menu -->
<div th:fragment="menu">
    <li style="background-color: #1b1b1b !important;" class="layui-nav-item" id="menu"></li>
</div>

</body>
</html>
<script>

    if (items.data > 0) {
        let dataUrl = "/push/inner/listData.action";
        $.ajax({
            type: "POST", url: ZMN_URL_ENV + "gateway-api.xiujiadian.com/mcs/api/plat/listPageByQuery",
            contentType: "application/json",
            dataType: "json", data: JSON.stringify({
                body: {
                    query: {
                        objectId: `${staffId}`,
                        receiverType: 70,
                        messageType: 150,
                        readStatus: 1,
                        pageIndex: 1,
                        pageSize: 5,
                    }
                }
            }),
            success: function (response) {
                if (response.status == 200) {
                    if (response.data.items.length > 0) {
                        $(".news-item").remove();
                        let dataHtml = spliceData(response.data.items);
                        $("#remindTip").append(dataHtml);
                        if (window.currentInnerMsgIndex == null) {
                            window.currentInnerMsgIndex = layer.open({
                                type: 1
                                , offset: 'rb'
                                , title: '提醒'
                                , closeBtn: 1
                                , shade: 0
                                , area: ['360px', '365px']
                                , moveType: 1 //拖拽模式，0或者1
                                , content: $('#innerMsgLayer')
                                , cancel: function () {
                                    // $.get('/push/inner/setMsgTemporaryStorage.action', {}, function () {
                                    // });
                                    layer.close(window.currentInnerMsgIndex);
                                    window.currentInnerMsgIndex = null;
                                }
                            });
                        }

                    } else {
                        layer.close(window.currentInnerMsgIndex);
                        window.currentInnerMsgIndex = null;
                    }
                } else {
                    layer.close(window.currentInnerMsgIndex);
                    window.currentInnerMsgIndex = null;
                }
            }
        });
    } else {
        layer.close(window.currentInnerMsgIndex);
        window.currentInnerMsgIndex = null;
    }
</script>